package com.mall.user.registerVerification;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @author qugr
 * @create 2020-07-10 21:23
 */
@Slf4j
@Component
public class RegisterMailDemo {

    @Value("${spring.mail.username}")
    private String source;

    @Autowired
    private JavaMailSender mailSender;

    public void sendMail(Map<String,String> mailMap){

        SimpleMailMessage message = new SimpleMailMessage();
        message.setFrom(source);
        message.setTo(mailMap.get("target"));
        message.setSubject("csmall商城激活");
        message.setText(mailMap.get("url"));
        mailSender.send(message);

    }
}
